package com.blog.config;

import com.blog.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")
                /* .excludePathPatterns(
                        "/articles",
                        "/articles/{id}",
                        "/articles/byTag/{tagId}",
                        "/articles/byUserId/{id}",
                        "/articles/byCondition",
                        "/articletags/{id}",
                        "/comments/article/{id}",
                        "/email",
                        "/hobbies/{id}",
                        "/notices",
                        "/notices/{id}",
                        "/sendQuestion",
                        "/tags",
                        "/register",
                        "/login",
                        "/users/{id}"
                )*/;
    }

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/**")
//                .addResourceLocations("classpath:/static/**");
//        registry.addResourceHandler("index.html")
//                .addResourceLocations("classpath:/static/index.html");
//        registry.addResourceHandler("favicon.ico")
//                .addResourceLocations("classpath:/static/favicon.ico");
//        registry.addResourceHandler("/assets/**")
//                .addResourceLocations("classpath:/static/assets/**");
//        WebMvcConfigurer.super.addResourceHandlers(registry);
//    }
}
